> ## Documentation Index
> Fetch the complete documentation index at: https://wb-21fd5541-wb_mcp_and_llms_rewrite.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# WeaveClient

> The WeaveClient class provides methods for interacting with the Weave service

The `WeaveClient` class is the primary interface for interacting with the Weave service. It provides methods for managing calls, datasets, models, and other Weave objects.

## Constructor

```python
from weave import WeaveClient

client = WeaveClient(project: str)
```

### Parameters

* **project** (`str`) - The project identifier in the format "entity/project"

## Methods

### add\_cost

Add custom cost tracking to a call.

```python
client.add_cost(
    costs: Dict[str, float],
    call_id: Optional[str] = None
) -> None
```

### Parameters

* **costs** (`Dict[str, float]`) - Dictionary of cost metrics (e.g., `{"prompt_tokens": 100, "completion_tokens": 50}`)
* **call\_id** (`Optional[str]`) - The call ID to add costs to. If None, uses the current call context.

### Example

```python
client.add_cost({
    "prompt_tokens": 100,
    "completion_tokens": 50,
    "total_cost": 0.002
})
```

### query\_costs

Query costs for calls with various filters.

```python
client.query_costs(
    project_id: Optional[str] = None,
    filters: Optional[Dict] = None
) -> List[Dict]
```

### purge\_costs

Remove custom costs by their IDs.

```python
client.purge_costs(cost_ids: List[str]) -> None
```

### get\_call

Retrieve a specific call by its ID.

```python
call = client.get_call(call_id: str) -> Call
```

### Parameters

* **call\_id** (`str`) - The unique identifier of the call

### Returns

* **Call** - A Call object containing the call details

### Example

```python
call = client.get_call("call_123456")
print(call.inputs)
print(call.output)
```

### get\_calls

Query multiple calls with filters.

```python
calls = client.get_calls(
    filter: Optional[CallsFilter] = None,
    limit: Optional[int] = None,
    offset: Optional[int] = None
) -> List[Call]
```

### Parameters

* **filter** (`Optional[CallsFilter]`) - Filter criteria for calls
* **limit** (`Optional[int]`) - Maximum number of calls to return
* **offset** (`Optional[int]`) - Number of calls to skip

### delete

Delete a call or calls.

```python
# Delete a single call
call.delete()

# Delete multiple calls
client.delete_calls(call_ids: List[str])
```

### set\_display\_name

Set or update the display name of a call.

```python
call.set_display_name(display_name: str) -> None
```

## Working with Datasets

### save

Save a dataset to Weave.

```python
dataset = weave.Dataset(rows=[...])
weave.publish(dataset, "my-dataset")
```

### get

Retrieve a dataset by name.

```python
dataset = weave.ref("my-dataset").get()
```

## Working with Models

### save

Save a model to Weave.

```python
model = MyModel(...)
weave.publish(model, "my-model")
```

### get

Retrieve a model by reference.

```python
model = weave.ref("my-model").get()
```

<Note>
  For complete examples and advanced usage, see the [Weave documentation](https://weave-docs.wandb.ai/).
</Note>
